﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.view.common.*;

    public class GuildShopConfig extends Object
    {
        private var _guildShopMap:Dictionary;
        private var _guildShopSellMap:Dictionary;
        private static var _instance:GuildShopConfig;

        public function GuildShopConfig()
        {
            this._guildShopMap = new Dictionary();
            this._guildShopSellMap = new Dictionary();
            if (_instance != null)
            {
                throw new Error(" GuildShopConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        private function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_guild_shop.json");
            this.write(_loc_1);
            _loc_1 = ConfigManager.instance.getJSONByFileName("t_guild_shop_sell.json");
            this.writeShopSell(_loc_1);
            return;
        }// end function

        private function writeShopSell(param1:Object) : void
        {
            var _loc_2:TGuildShopSell = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TGuildShopSell();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._guildShopSellMap[_loc_2.itemCode] = _loc_2;
            }
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TGuildShop = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TGuildShop();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._guildShopMap[_loc_2.shopLevel] = _loc_2;
            }
            return;
        }// end function

        public function getGuildShopByLevel(param1:int) : TGuildShop
        {
            return this._guildShopMap[param1];
        }// end function

        public function getGuildShopSellByCode(param1:int) : TGuildShopSell
        {
            return this._guildShopSellMap[param1];
        }// end function

        public function getShopTabByLevel(param1:int) : Array
        {
            var _loc_4:Object = null;
            var _loc_2:* = new Array();
            var _loc_3:* = this.getGuildShopByLevel(param1);
            _loc_4 = {name:_loc_3.shopLevel, label:_loc_3.shopName};
            _loc_2.push(_loc_4);
            return _loc_2;
        }// end function

        public static function get instance() : GuildShopConfig
        {
            if (_instance == null)
            {
                _instance = new GuildShopConfig;
            }
            return _instance;
        }// end function

    }
}
